#load data on top European routes extracted from MongoDb
european_2020_routes <- read_csv("Data/top_european_routes_2020.csv")
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## .default = col_character(),
## day = col_datetime(format = ""),
## firstseen = col_datetime(format = ""),
## lastseen = col_datetime(format = ""),
## altitude_1 = col_double(),
## altitude_2 = col_double(),
## origin_lon = col_double(),
## origin_lat = col_double(),
## dest_lon = col_double(),
## dest_lat = col_double()
## )
## ℹ Use `spec()` for the full column specifications.
european_2020_routes %>%
group_by(origin) %>%
summarise(n())
## `summarise()` ungrouping output (override with `.groups` argument)
## # A tibble: 22 x 2
## origin `n()`
## <chr> <int>
## 1 EBBR 5321
## 2 EDDB 1937
## 3 EDDF 12688
## 4 EDDM 9814
## 5 EGCC 5051
## 6 EGLL 16750
## 7 EGPH 3206
## 8 EHAM 13277
## 9 EIDW 8146
## 10 ENGM 4710
## # … with 12 more rows
#filter out destinations that are not in Europe and convert dates using lubridate
european_2020_routes <- european_2020_routes %>%
filter(origin!=destination) %>%
mutate(day= as_date(day, tz = NULL),
route= gsub(" ", "", paste(origin,"-", destination)))%>%
filter(origin!="KJFK", destination!="KJFK") %>%
filter(day>"2020-01-31")
#load shape file for Europe
Europe <- ne_countries(scale = 'large', type = 'map_units', returnclass = 'sf', continent="Europe")
#trim map to get only western Europe
Europe <- sf::st_crop(Europe, xmin = -15, xmax = 40, ymin = 25, ymax = 62)
## although coordinates are longitude/latitude, st_intersection assumes that they are planar
## Warning: attribute variables are assumed to be spatially constant throughout all
## geometries
#plot each flight in Europe between start of Feb and end of April
p <- ggplot() +
geom_sf(data = Europe, size = 0.125) +
geom_curve(
data = european_2020_routes,
aes(x = origin_lon, y = origin_lat, xend = dest_lon , yend = dest_lat),
curvature = 0.2, color= "#2c7fb8", size=0.1, alpha=0.4)+
theme_void()+
theme(
plot.title = element_text(color="black", size=16, face="bold"),
plot.subtitle = element_text(color="black", size=14, face="plain")
)
p <- p+ transition_time(day) +
labs(title = "Air traffic all but dissapeared in European airspace after COVID-19 struck",
subtitle= "Daily flights between 21 major airports dropped sharply in late March \n\nDate: {format(frame_time, '%b %d, %Y')}"
)
#Use gganimate to create an animated visualization
animate(p, nframes = 80, fps=7, height = 800, width =1200)
## On major and long global routes
#load data on global routes extracted from MongoDb
global_2020_routes <- read_csv("Data/top_global_routes_2020.csv")
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## .default = col_character(),
## day = col_datetime(format = ""),
## firstseen = col_datetime(format = ""),
## lastseen = col_datetime(format = ""),
## altitude_1 = col_double(),
## altitude_2 = col_double(),
## origin_lon = col_double(),
## origin_lat = col_double(),
## dest_lon = col_double(),
## dest_lat = col_double()
## )
## ℹ Use `spec()` for the full column specifications.
global_2020_routes <- global_2020_routes %>%
filter(origin!=destination) %>%
mutate(day= as_date(day, tz = NULL),
route= gsub(" ", "", paste(origin,"-", destination)))
#load shape file of the earth from rnaturalearthhires
world <- ne_countries(scale = "large", returnclass = "sf") %>%
filter(name != "Antarctica")
p <- ggplot() +
geom_sf(data = world , size = 0.125) +
geom_curve(
data = global_2020_routes,
aes(x = origin_lon, y = origin_lat, xend = dest_lon , yend = dest_lat),
curvature = 0.2, color= "#2c7fb8", size=0.1, alpha=0.4)+
theme_void()+
theme(
plot.title = element_text(color="black", size=16, face="bold"),
plot.subtitle = element_text(color="black", size=14, face="plain")
)
p <- p+ transition_time(day) +
labs(title = "COVID-19 hit long international routes very hard",
subtitle= "Daily intercontinental flights between 31 major global airports \ndropped sharply in late March- early April \n\nDate: {format(frame_time, '%b %d, %Y')}"
)
#Use gganimate to create an animated visualization
animate(p, nframes = 80, fps=7, height = 800, width =1200)